package com.edu.neusoft.student.util;


import com.edu.neusoft.student.domain.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.concurrent.TimeUnit;

@Service
public class RedisStudentService {

    @Autowired
    private RedisCache redisCache;

    private static final String KEY_PREFIX = "Student:";

    public <T> void cacheResObj(Integer id, T object) {
        redisCache.setCacheObject(KEY_PREFIX + id,object, 3, TimeUnit.MINUTES);
    }

    public <T> T getResObj(Integer id) {
        return redisCache.getCacheObject(KEY_PREFIX + id);
    }
}